package com.silence.gankio.adapter

import android.view.View
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.silence.gankio.R
import com.silence.gankio.bean.GankIoData

class GankAndroidAdapter(data: MutableList<GankIoData>?) :
    BaseQuickAdapter<GankIoData, BaseViewHolder>(R.layout.item_gank_android, data) {

    override fun convert(helper: BaseViewHolder, item: GankIoData?) {
        item?.let {
            helper.setText(R.id.item_tv_title, it.desc)
            val ivPhoto = helper.getView<ImageView>(R.id.item_iv_photo)
            if (it.images.size > 0) {
                ivPhoto.visibility = View.VISIBLE
                Glide.with(mContext)
                    .load(it.images[0])
                    .asBitmap()
                    .into(ivPhoto)
            } else {
                ivPhoto.visibility = View.GONE
            }
        }

    }
}